/**
 * Created by kk580 on 2017/8/31.
 */
"use strict";
var http=require('http');

module.exports = function () {
    var body = {
        "data": {
            "id": id,
            "zjCount": zjCount,
            "number": number
        }
    };

    var bodyString = JSON.stringify(body);

    var headers = {
        'Content-Type': 'application/json',
        'Content-Length': bodyString.length
    };

    var options = {
        host: '127.0.0.1',
        port: 80,
        path: '/admin778899.php/api/kaijiang',
        method: 'POST',
        headers: headers
    };

    var req = http.request(options, function (res) {

        res.setEncoding('utf-8');

        var responseString = '';

        res.on('data', function (data) {
            responseString += data;
            log(data);
        });

        res.on('end', function (res) {
            //这里接收的参数是字符串形式,需要格式化成json格式使用
            //var resultObject = JSON.parse(responseString);
            log(res);
        });

        req.on('error', function (e) {
            // TODO: handle error.
            log('-----error-------', e);
        });
    });
    req.write(bodyString);
    req.end();
};